﻿@using rentit03_client.Models
@model dynamic
@{
    const int width = 4;
}
@if (ViewBag.Media != null)
{
    <div class="movies">
        @for (var i = 0; i <= ViewBag.Media.Count / width; i++)
        {

            <div class="row">
                @for (var j = i * width; j < Math.Min((i + 1) * width, ViewBag.Media.Count); j++)
                {
                    MovieObj media = ViewBag.Media[j];

                    <div class="span2 movie thumbnail" rel="popover" data-content="@media.Description" data-original-title="@media.Title (@media.Year)">
                        @{ var src = (media.CoverUrl == null || media.CoverUrl.Equals("N/A")) ? "http://placehold.it/140x200" : media.CoverUrl; }
                        <a href="@Url.Action("Index", "Movie", new { @id = media.Id })">
                            <img class="poster" src="@src" alt="@media.Title">
                        </a>
                        <div class="star-rating" data-rating="@media.Rating">
                        </div>
                        <a href="@Url.Action("Index", "Movie", new { @id = media.Id })">
                            <h4 style="display: inline">@media.Title</h4>
                        </a>
                    </div>
                }
            </div>
        }
    </div>
    @Html.Partial("_Pager")
}